package com.huang.web.controller;

import com.huang.domain.Children;
import com.huang.domain.ChinaTotal;
import com.huang.service.ChildrenService;
import com.huang.service.ChinaTotalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/cdata")
public class CDataController {
    @Autowired
    private ChinaTotalService chinaTotalService;
    @Autowired
    private ChildrenService childrenService;

    @RequestMapping("/map")//入口
    public String map() {
        return "/cdata/cdata-list";
    }

    @RequestMapping("/edit")//更新或者添加
    public void add() {

    }


    @RequestMapping("/ctotal")//异步请求返回国内总数据json
    @ResponseBody
    public ChinaTotal ctotal() {
        //ChinaTotal chinaTotal = ChinaTotalUtil.getChinaTotal();
        //chinaTotal.setId(1);
        ChinaTotal chinaTotal = chinaTotalService.findAll();
        return chinaTotal;
    }


    @RequestMapping("/cmap")//异步请求返回地图数据json
    @ResponseBody
    public List cmap() {
        List<Children> childrenList = childrenService.findAll();
        //System.out.println("childrenList = " + childrenList);
        return childrenList;
    }


}
